﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel;
using V2TEK.NET.SH.Silverlight.GanttView.SharePointLists;


namespace V2TEK.NET.SH.Silverlight.GanttView
{
    public class ServiceManager
    {
        private static BasicHttpBinding GetBasicHttpBinding()
        {
            //BasicHttpBinding 定义 
            //BasicHttpBinding binding = new BasicHttpBinding(
            //    Application.Current.Host.Source.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase)
            //    ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None);
            BasicHttpBinding binding = new BasicHttpBinding();

            binding.MaxReceivedMessageSize = int.MaxValue;

            binding.MaxBufferSize = int.MaxValue;
            return binding;
        }

        public static ListsSoapClient GetShartPointListsService(string dataServiceUrl)
        {
            BasicHttpBinding bind = GetBasicHttpBinding();
            ListsSoapClient client = new ListsSoapClient(bind, new EndpointAddress(dataServiceUrl));
            return client;
        }

        public static ListsSoapClient GetShartPointListsService()
        {
            return GetShartPointListsService(Application.Current.Host.InitParams["dataService"].TrimEnd('/') + "/_vti_bin/lists.asmx");
        }
    }
}
